package com.udian.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.udian.domain.User;

/**
 *
 * 创建时间：2015年12月1日 上午11:48:37  
 * 项目名称：frame  
 * @author <a href="fairwork@163.com">zhu.wending</a>
 *  
 * @version 1.0   
 * @since JDK 1.7
 */
@Repository
public class UserDao {
	
	@Autowired
	private SqlSession frameSqlSession;
	
	public User getUser(Long id){
		Map<String,Object> params = new HashMap<String, Object>();
		params.put("id", id);
		return frameSqlSession.selectOne("user.select",params);
	}
	
	public List<User> getUserList(Map<String,Object> paramsMap){
		return frameSqlSession.selectOne("user.selectList",paramsMap);
	}
	
	
	public User addUser(User user){
		 frameSqlSession.insert("user.insert",user);
		 return user;
	}
	
	public User updateUser(User user){
		 frameSqlSession.update("user.update",user);
		 return user;
	}
	
	public int deleteUser(Long id){
		 return frameSqlSession.delete("user.delete",id);
	}
	
}
